module.exports = app => {
  const { STRING, BOOLEAN  } = app.Sequelize;

  const Group = app.model.define('group', {
    name: {
      type: STRING,
      unique: 'name'     //todo 添加唯一性索引
    },
    photo: {
      type: STRING
    },
    introduction: {
      type: STRING
    },
    disabled: {
      type: BOOLEAN
    }
  },
      // {
      //   indexes: [
      //     { unique: true, fields: ['name'] }
      //   ]
      // }
  );
  Group.associate = function() {
    //todo 分组表和用户表多对多  Many-To-Many associations
    app.model.Group.belongsToMany(app.model.User, { through: 'user_group' });
  };

  return Group;
};
